package com.flame.core.utils.cipher;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * Base64Cipher
 *
 * @author wuxintong
 * @since 2023/1/28
 */
public class Base64Cipher implements FlameCipher {

    @Override
    public String encrypt(String data) {
        return Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
    }

    @Override
    public String decrypt(String data) {
        return new String(Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
    }
}
